package com.open.capacity.task.controller;

import com.open.capacity.common.web.PageResult;
import com.open.capacity.common.web.Result;
import com.open.capacity.task.model.TaskType;
import com.open.capacity.task.service.TaskTypeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@Slf4j
@Api(tags = "TaskType api")
@RestController
@RequestMapping("/taskType")
public class TaskTypeController {
    @Autowired
    TaskTypeService taskTypeService;
    /**
     * 根据条件查询所有的任务类型信息
     * @param params :前台传过来的一个map集合参数
     */
    @PostMapping("/getTaskType")
    @ApiOperation(value = "查询任务类型的信息")
    public PageResult<TaskType> getTaskType(@RequestParam Map<String,Object> params){
        return taskTypeService.getTaskType(params);
    }

    @PostMapping("/add")
    @ApiOperation(value = "新增任务类型")
    public Result add(@RequestBody TaskType taskType){
        return taskTypeService.add(taskType);
    }

    @DeleteMapping("/{id}")
    @ApiOperation(value = "删除任务类型")
    public Result del(@PathVariable String id){
        return taskTypeService.del(id);
    }
    @PostMapping("/edit")
    @ApiOperation(value = "修改任务类型")
    public Result edit(@RequestBody TaskType taskType){
        return taskTypeService.edit(taskType);
    }
}
